package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.discovery.bean.ArticleListResponse;
import com.rongshu.view.penpal.bean.PenpalArticleResponse;
import com.rongshu.view.userInfo.entity.ShareInfo;
import com.rongshu.view.userInfo.iview.ShareArticleView;

import rx.Subscriber;

public class ShareArticlePresenter extends BasePresenter<ShareArticleView> {

    public ShareArticlePresenter(Context context) {
        super(context);
    }

    /**
     * 我的分享-文章
     */
    public void getMyShareArticle(int user_id, int type, int page, int pagesize, String sign) {
        RetorfitService.getMyShareArticle(user_id, type, page, pagesize, sign)
                .subscribe(new Subscriber<ArticleListResponse>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(ArticleListResponse shareInfo) {
                        if (getView() != null) {
                            getView().onMyShareArticle(shareInfo);
                        }
                    }
                });
    }

    /**
     * 我的分享-帖子
     */
    public void getMySharePost(int user_id, int type, int page, int pagesize, String sign) {
        RetorfitService.getMySharePost(user_id, type, page, pagesize, sign)
                .subscribe(new Subscriber<PenpalArticleResponse>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(PenpalArticleResponse shareInfo) {
                        if (getView() != null) {
                            getView().onMySharePost(shareInfo);
                        }
                    }
                });
    }
}
